<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>
    菜单管理
</title>
<link rel="shortcut icon" href="../../favicon.ico" type="image/x-icon"/>
<link rel="stylesheet" href="../../lib/webuploader/0.1.5/webuploader.css"/>
<link rel="stylesheet" href="../../css/demo.css"/>
<link rel="stylesheet" href="../../lib/zTree/v3/css/zTreeStyle/zTreeStyle.css"/>

<style>
   .ui-dialog-content{overflow-y:auto}
   .uiTypeMuShow,.uiTypeBuShow{position:relative;top:2px}
   .input-r{position:relative;top:2px}
   .label-r{margin-right:13px}
   .edit-label-r{margin-right:13px}
   .form_table td label.formDescription{padding-right: 15px;}
   .formArea{border:0;padding:0 5px;margin-top: -10px;}
   .formArea input{position:relative;top:2px;margin-right:5px}
   .formArea select{width: 140px;height: 28px;border: 1px solid lightgray;padding: 0 0 0 5px;}
   .showSelect {width: 140px;height: 28px;border: 1px solid lightgray;padding: 0 0 0 5px;}
   .formArea textarea{resize:no}
   .r-space{margin-right:5px}
   #filePickerS,.ui-textcolorml{display:inline}
   .webuploader-pick{top:14px;margin-right:15px}
   .ui-dialog-body {
        padding: 10px;        
    }
    .imgPick{
        width:80px;
        height:40px;
    }
    label.w100{
       width:100px;
    }
   .ui-dialog-body {
        padding: 10px;
        
        }
        .imgPick{
            width:80px;
            height:40px;
        }
        label.w100{
           width:100px;
        }
        
      .ui-dialog-content {
        /*height:450px;*/
        overflow: auto; 
      }
      
      #J_upload_img {
        border: 1px solid #f5f5f5;
      }
      .img-left{
        display:inline-block;
        width:62px;
        height:62px;
        }
        .clearfix,.image-box,.image-box.four{
            width:100%;
            height:100%;
        }
        .weblink ul
        {
            margin:0px;
            height:60px;
            list-style-type:none; /*********************/
            overflow:hidden; 
            width:75%;
        }
        
        .weblink ul li
        {
            float:left; /*********************/
            margin-right:10px;
            list-style-type:none; /*********************/
            height:60px;
            width:60px;
            text-align:center;
            font-size:14px;
        
        }
        .weblink a
        {
            height:10px;
            width:62px;
            display:inline-block; /*********************/
            margin-top:6px;
            line-height:30px;
        
        }
        .ui-Upload_Center{
           padding:0
        }
        .ui-form-table{border-bottom:0;margin-bottom:100px}  
        input.ui-inputWidthDataPoint{height:40px}
        .ke-input-text{height:35px}  
        .image-box .webuploader-pick{opacity:0;width:100%;height:100%}
        .excelProcess {
            height: 20px;
            background: #ebebeb;
            border-left: 1px solid transparent;
            border-right: 1px solid transparent;
            border-radius: 10px;
            line-height:20px;
            text-align:center;
            color:white;
            position:relative;
        }
        .excelProcess .progress{
            background:#666666;
            height:100%;            
            border-radius:10px;
        }
        .excelProcess span{
            position:absolute;
            top:0;
            font-size:8px;
            left:25%;
        }
        .upload_btn {
            border:1px solid #f0f0f0
        }
        .disable_div_warp{position:absolute;top:0;left:0;z-index:1;width:90%;height:100%}
        .formArea-B{border-top:0;padding-top:0}
</style>
</head>
<body style='height:900px'>
    <div class="formItem">       
    </div>
    <div class="formItem formArea-B moduleManage">
        <div class="form_container fn-clear onedv fn-left" style="height:450px">
            <div class="treewh" style="height:450px;overflow-y: scroll;overflow-x: hidden;">
                <div class="form_container fn-clear">
                    <div class="zui">
                        <ul id="J_zTree" class="ztree ability-catalog-list fn-clear">
                        </ul>
                    </div>
                </div>
            </div>
            <div class="normalBtnArea ft-left">
                <a class="normalBtn BGblue" href="javascript:;" id="J_addTree">增加节点</a>
                <a class="normalBtn BGblue" href="javascript:;" id="J_delTree">删除节点</a>
                <a class="normalBtn BGblue" href="javascript:;" id="J_editTree">编辑节点</a>
            </div>
        </div>
        <div class="dv_border">
            <table class="form_table" >
                <tbody>
                    <tr>
                        <td width="120">
                            <label class="formDescription">
                            	<span class="fn-high">*</span>界面名称:
                            </label>
                        </td>
                        <td>
                            <input class="inputWidth260 width100" type="text" id="uiNm" name="uiNm" disabled="true"/>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <label class="formDescription">
                                <span class="fn-high">*</span>界面类型:
                            </label>
                        </td>
                        <td>
                            <input type="radio" class="uiTypeMuShow" name="uiTypeCd" value="0"  disabled="true"/>
                            <label class="r-space">菜单</label>
                            <input type="radio" class="uiTypeBuShow" name="uiTypeCd" value="1" disabled="true" />
                            <label> 按钮</label>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <label class="formDescription">
                                <span class="fn-high"></span>URL参数:
                            </label>
                        </td>
                        <td>
                            <input class="inputWidth260 width100" type="text" id="urlAddr" name="urlAddr" disabled="true"/>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <label class="formDescription">
                                <span class="fn-high"></span>icon URL:
                            </label>
                        </td>
                        <td>
                            <img width="60" height="60" id="iconUrlAddr" src="../../img/helppoor/personIcon.gif" />
                            <img width="60" height="60" id="iconUrlAddrHover" src="../../img/helppoor/personIcon.gif" />
                            <img width="60" height="60" id="iconUrlAddrSelected" src="../../img/helppoor/personIcon.gif" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <label class="formDescription">
                                <span class="fn-high">*</span>界面权限代码:
                            </label>
                        </td>
                        <td>
                            <input class="inputWidth260 width100" type="text" id="uiPrivCd" name="uiPrivCd" disabled="true"
                            />
                        </td>
                    </tr> 
                     <tr>
                        <td>
                            <label class="formDescription">
                                <span class="fn-high">*</span>菜单排序序号:
                            </label>
                        </td>
                        <td>
                            <input class="inputWidth260 width100" type="text" id="J_seqno" name="J_seqno" disabled="true"/>
                        </td>
                    </tr>
                    
                    <tr>
                        <td valign="top">
                            <label class="formDescription">界面描述：</label>
                        </td>
                        <td>
                            <textarea rows="8" cols="40" style="resize:none;" id="uiDesc" name="uiDesc" disabled="true" class="width100"></textarea>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>
	<script src="../../jquery/1.9.1/jquery.js"></script>
    <script src="../../lib/webuploader/0.1.5/webuploader.js"></script>
    <script src="../../js/lib.min.js"></script>
	<script src="../../js/requirejsConfigObj.js"></script>
	<script src="../../js/requirejs/2.1.17.js"></script>
	<script src="../../js/common.min.js"></script>
	<script src="../../lib/zTree/v3/js/jquery.ztree.core-3.5.js"></script>
    <script src="../../lib/zTree/v3/js/jquery.ztree.excheck-3.5.js"></script>
       
    <script type="text/javascript">
        
        var upRegnStr = '';//上级菜单应用区域
        var upAddrLvl = '';//上级菜单应用级别
        var ipAddr = '';//ftp服务器地址
        //当前所有省信息存储
        var provInfoList=null;

 var setting = {
		 view : {
             dblClickExpand : true, //去除双击事件，单击展开收缩
             showLine : false, //不显示虚线
             selectedMulti : false
         },
         data : {
            keep : {
                 parent : true,
                 leaf : true
             },
             edit : {
                 enable : true,
                 showRemoveBtn : false,
                 showRenameBtn : false
             },
             key : {
                 children : "subList", //json中树子节点的key值
                 name : "uiNm" //json中需要展示树的key值
             }, 
             simpleData: {
     			enable: true,
     			idKey: "uiId",
     	        pIdKey: "parentId",
     	        rootPId: "0"
     		}
        },
        callback : {
             beforeRemove : beforeRemove,
             beforeClick : beforeClick
         }
		};

        $(function() {
          initTree();
            //添加事件
            $('#J_addTree').bind('click', function() {
                                var zTree = $.fn.zTree.getZTreeObj("J_zTree"), 
                               	nodes = zTree.getSelectedNodes(), 
                               	treeNode = nodes[0] 
                                
                                var content = ' <div method="post" action="#" class="open_win">'
                                        + '<form class="record-search-form record-search-min record-search-form-border" id="J_formAdd" name="J_formAdd" ><div class="formArea">'
                                        + ' <table width="100%" class="form_table_pro" >'
                                        + '<tbody>'
                                        + ' <tr>'
                                        + '<td width="30%"><label class="formDescription" ><span class="fn-high">*</span>菜单级别：</label></td>'
                                        + '<td><select class="inputWidth260" id="menuStsCd" name="menuStsCd"><option value="1001">一级菜单</option><option value="1002">二级菜单</option></select></td>'
                                        + ' </tr>'
                                        + ' <tr>'
                                        + '<td width="30%"><label class="formDescription" ><span class="fn-high">*</span>界面名称：</label></td>'
                                        + '<td><input class="inputWidth260" id="uiNm" name="uiNm" type="text"/></td>'
                                        + ' </tr>'
                                        + '<tr>'
                                        + '<td><label class="formDescription"><span class="fn-high">*</span>界面类型：</label></td>'
                                        + ' <td><input type="radio" class="uiTypeMu" name="uiTypeCd" value="0" checked=true/><label class="r-space">菜单</label>'
                                        + '<input type="radio" class="uiTypeBu" name="uiTypeCd" value="1" /><label>按钮</label></td>'
                                        + ' </tr>'
                                        + ' <tr>'
                                        + '<td><label class="formDescription" ><span class="fn-high"></span>URL参数：</label></td>'
                                        + '<td><input class="inputWidth260" id="urlAddr" name="urlAddr" type="text"/></td>'
                                        + ' </tr>'
                                        + ' <tr>'
                                        + '<td><label class="formDescription" ><span class="fn-high"></span>ICON URL：</label></td>'
                                        + '<td class="weblink" style="margin:0;vertical-align:top;">' 
                                        + '<ul class="information-main" id="parentUl" style="height:90px;">' 
                                        + '<li class="informationMain-li" >' 
                                        + '<div class="img-left">' 
                                        + '<div id="fileList1" class="clearfix">' 
                                        + '<input type="hidden" id="fileName1" class="fileName" name="fileName1"/>' 
                                        + '<input type="hidden" id="filePath1" class="filePath" name="filePath1"/>' 
                                        + '<div id="fileListS1" class="image_style img_thumbnail" style="display:none;"></div>' 
                                        + '<div class="image-box four img_btn">' 
                                        + '<label class="upload_btn" id="filePickerS1"></label>' 
                                        + '</div>' 
                                        + '</div>' 
                                        + '</div>' 
                                        + '</li>' 
                                        + '<li class="informationMain-li" >' 
                                        + '<div class="img-left">' 
                                        + '<div id="fileList2" class="clearfix">' 
                                        + '<input type="hidden" id="fileName2" class="fileName" name="fileName2"/>' 
                                        + '<input type="hidden" id="filePath2" class="filePath" name="filePath2"/>' 
                                        + '<div id="fileListS2" class="image_style img_thumbnail" style="display:none;"></div>' 
                                        + '<div class="image-box four img_btn">' 
                                        + '<label class="upload_btn" id="filePickerS2"></label>' 
                                        + '</div>' 
                                        + '</div>' 
                                        + '</div>' 
                                        + '</li>' 
                                        + '<li class="informationMain-li" >' 
                                        + '<div class="img-left">' 
                                        + '<div id="fileList3" class="clearfix">' 
                                        + '<input type="hidden" id="fileName3" class="fileName" name="fileName3"/>' 
                                        + '<input type="hidden" id="filePath3" class="filePath" name="filePath3"/>' 
                                        + '<div id="fileListS3" class="image_style img_thumbnail" style="display:none;"></div>' 
                                        + '<div class="image-box four img_btn">' 
                                        + '<label class="upload_btn" id="filePickerS3"></label>' 
                                        + '</div>' 
                                        + '</div>' 
                                        + '</div>' 
                                        + '</li>' 
                                        + '</ul>' 
                                        + '</td>'
                                        + ' </tr>'
                                        + ' <tr>'
                                        + '<td><label class="formDescription" ><span class="fn-high">*</span>界面权限代码：</label></td>'
                                        + '<td><input class="inputWidth260" id="uiPrivCd" name="uiPrivCd" type="text"/></td>'
                                        + ' </tr>' 
                                        + ' <tr>'
                                        + '<td><label class="formDescription" ><span class="fn-high">*</span>菜单排序序号：</label></td>'
                                        + '<td><input class="inputWidth260" id="argeSeqno" name="argeSeqno" type="text"/></td>'
                                        + '</tr>'
                                        + '<tr>'
                                        + '<td><label class="formDescription">界面描述：</label></td>'
                                        + '<td><textarea  id="UI_DESC" style="height:80px;resize:none;" rows="10" cols="30" id="uiDesc" name="uiDesc"></textarea></td>'
                                        + '</tr></tbody></table></div> </form></div>'
                                Util.dialog.openDiv({
                                    content : content,
                                    title : '新建',
                                    width : "650px",
                                    height : "350px",
                                    modal : true,
                                    okVal : '确定',
                                    okCallback : addOk,
                                    cancelVal : '取消',
                                    cancelCallback : {}
                                });
                           
                                
                                //initWeb('#fileListS','#filePickerS','#J_formAdd');
                                //初始化图片上传
                                //initWeb('#fileListS1','#filePickerS1','#filePath1','#fileName1');
                               // initWeb('#fileListS2','#filePickerS2','#filePath2','#fileName2');
                                //initWeb('#fileListS3','#filePickerS3','#filePath3','#fileName3');
                                
                            })

            //删除节点
            $('#J_delTree').bind('click', function() {
                                var zTree = $.fn.zTree.getZTreeObj("J_zTree"), nodes = zTree
                                        .getSelectedNodes(), treeNode = nodes[0];
                                if (nodes.length == 0) {
                                    Util.dialog.tips("请先选择一个节点!");
                                    return;
                                }
                                //param2: 触发回调函数（beforeRemove）
                                zTree.removeNode(treeNode, true);
                            })
            $('#J_editTree').bind('click', function() {
                                var zTree = $.fn.zTree.getZTreeObj("J_zTree"), //获取树对象
                                nodes = zTree.getSelectedNodes(), //获取选中的树节点对象，数组类型
                                treeNode = nodes[0];
                                if (nodes.length == 0) {
                                    Util.dialog.tips("请先选择一个节点!");
                                    return;
                                }
                                var content = '<div method="post" action="#" >'
                                        + '<form class="record-search-form record-search-min record-search-form-border" id="J_formEdit" name="J_formEdit" ><div class="formArea">'
                                        + ' <table width="100%" class="form_table_pro" >'
                                        + '<tbody>'
                                        + ' <tr>'
                                        + '<td width="20%"><label class="formDescription" ><span class="fn-high">*</span>界面名称：</label></td>'
                                        + '<td ><input class="inputWidth260" type="text" id="uiName" name="uiNm" value="'+treeNode.uiNm+'"/></td>'
                                        + ' </tr>'
                                        + '<tr>'
                                        + '<td ><label class="formDescription"><span class="fn-high">*</span>界面类型：</label></td>'
                                        + ' <td><input class="uiTypeMu" type="radio" name="uiType" value="0" /><label class="r-space">菜单</label>'
                                        + '<input class="uiTypeBu" type="radio" name="uiType" value="1" /><label>按钮</label></td>'
                                        + ' </tr>'
                                        + ' <tr>'
                                        + '<td ><label class="formDescription" ><span class="fn-high"></span>URL参数：</label></td>'
                                        + '<td><input class="inputWidth260" id="urlAddress" name="urlAddr" type="text" value="'+treeNode.urlAddr+'"/></td>'
                                        + ' </tr>'
                                        + ' <tr>'
                                        + '<td><label class="formDescription" ><span class="fn-high"></span>ICON URL：</label></td>'
                                        + '<td class="weblink" style="margin:0;vertical-align:top;">' 
                                        + '<ul class="information-main" id="parentUl" style="height:90px;">' 
                                        + '<li class="informationMain-li" >' 
                                        + '<div class="img-left">' 
                                        + '<div id="fileList1" class="clearfix">' 
                                        + '<input type="hidden" id="fileName1" class="fileName" name="fileName1"/>' 
                                        + '<input type="hidden" id="filePath1" class="filePath" name="filePath1"/>' 
                                        + '<div id="fileListS1" class="image_style img_thumbnail" style="display:none;"></div>' 
                                        + '<div class="image-box four img_btn">' 
                                        + '<label class="upload_btn" id="filePickerS1"></label>' 
                                        + '</div>' 
                                        + '</div>' 
                                        + '</div>' 
                                        + '</li>' 
                                        + '<li class="informationMain-li" >' 
                                        + '<div class="img-left">' 
                                        + '<div id="fileList2" class="clearfix">' 
                                        + '<input type="hidden" id="fileName2" class="fileName" name="fileName2"/>' 
                                        + '<input type="hidden" id="filePath2" class="filePath" name="filePath2"/>' 
                                        + '<div id="fileListS2" class="image_style img_thumbnail" style="display:none;"></div>' 
                                        + '<div class="image-box four img_btn">' 
                                        + '<label class="upload_btn" id="filePickerS2"></label>' 
                                        + '</div>' 
                                        + '</div>' 
                                        + '</div>' 
                                        + '</li>' 
                                        + '<li class="informationMain-li" >' 
                                        + '<div class="img-left">' 
                                        + '<div id="fileList3" class="clearfix">' 
                                        + '<input type="hidden" id="fileName3" class="fileName" name="fileName3"/>' 
                                        + '<input type="hidden" id="filePath3" class="filePath" name="filePath3"/>' 
                                        + '<div id="fileListS3" class="image_style img_thumbnail" style="display:none;"></div>' 
                                        + '<div class="image-box four img_btn">' 
                                        + '<label class="upload_btn" id="filePickerS3"></label>' 
                                        + '</div>' 
                                        + '</div>' 
                                        + '</div>' 
                                        + '</li>' 
                                        + '</ul>'
                                        + '</td>'
                                        + ' </tr>'
                                        + ' <tr>'
                                        + '<td ><label class="formDescription" ><span class="fn-high">*</span>界面权限代码：</label></td>'
                                        + '<td><input class="inputWidth260" id="uiPriv" name="uiPrivCd" type="text" value ="'+treeNode.uiPrivCd+'"/></td>'
                                        + ' </tr>'
                                       
                                        
                                        + ' <tr>'
                                        + '<td ><label class="formDescription" ><span class="fn-high">*</span>菜单排序序号：</label></td>'
                                        + '<td><input class="inputWidth260" id="argeSeqnoE" name="argeSeqNoo" type="text" value =""/></td>'
                                        + ' </tr>'
                                        + '  <tr>'
                                        + ' <td ><label class="formDescription">界面描述：</label></td>'
                                        + '  <td><textarea  id="uiDesc" style="height:80px;resize:none;" rows="10" cols="30" name="uiDesc" >'+treeNode.uiDesc+'</textarea></td>'
                                        + ' </tr>     </tbody></table></div></form></div>'
                                Util.dialog.openDiv({
                                    content : content,
                                    title : '编辑',
                                    width : "650px",
                                    height : "350px",
                                    modal : true,
                                    okVal : '确定',
                                    okCallback : editOk,
                                    cancelVal : '取消',
                                    cancelCallback : {}
                                });
                                //initWeb('#fileListS1','#filePickerS1','#filePath1','#fileName1');
                               // initWeb('#fileListS2','#filePickerS2','#filePath2','#fileName2');
                               // initWeb('#fileListS3','#filePickerS3','#filePath3','#fileName3');
                               
                                var str = '';
                                if(treeNode.iconUrlAddr != '' && treeNode.iconUrlAddr != null && typeof treeNode.iconUrlAddr != 'undefined'){
                                    str = '<div class="file-item thumbnail"><img style="width:60px;height:60px;" src="'+ipAddr+treeNode.iconUrlAddr+'">'
                                        +'<div class="delpic"><span style="color: #08c;" onclick="delPicF(this,1)">删除图片</span></div></div>';
	                                $("#fileList1").find(".image-box").hide();
                                }
                                $("#fileList1").append(str);//加载图片
                                $("#filePath1").val(treeNode.iconUrlAddr);
                                //$("#J_formEdit #filePath").val(treeNode.ICON_URL_ADDR);
                                
                                var str2 = '';
                                if(treeNode.iconUrlAddrHover != '' && treeNode.iconUrlAddrHover != null && typeof treeNode.iconUrlAddrHover != 'undefined'){
                                    //str="<div class='file-item thumbnail upload-state-done' style='width:100px;'><img src="+ipAddr+treeNode.ICON_URL_ADDR+" width='60' height='60'><div class='delpic' onclick='delPicF(this);'><span id="+treeNode.ICON_URL_ADDR+">删除图片</span></div></div>";
                                    str2 = '<div class="file-item thumbnail"><img style="width:60px;height:60px;" src="'+ipAddr+treeNode.iconUrlAddrHover+'">'
                                        +'<div class="delpic"><span style="color: #08c;" onclick="delPicF(this,2)">删除图片</span></div></div>';
	                                $("#fileList2").find(".image-box").hide();
                                }
                                $("#fileList2").append(str2);//加载图片
                                $("#filePath2").val(treeNode.iconUrlAddrHover);
                                
                                var str3 = '';
                                if(treeNode.iconUrlAddrSelected != '' && treeNode.iconUrlAddrSelected != null && typeof treeNode.iconUrlAddrSelected != 'undefined'){
                                    str3 = '<div class="file-item thumbnail"><img style="width:60px;height:60px;" src="'+ipAddr+treeNode.iconUrlAddrSelected+'">'
                                        +'<div class="delpic"><span style="color: #08c;" onclick="delPicF(this,2)">删除图片</span></div></div>';
	                                $("#fileList3").find(".image-box").hide();
                                }
                                $("#fileList3").append(str3);//加载图片
                                $("#filePath3").val(treeNode.iconUrlAddrSelected);

                                if (treeNode.uiTypeCd == "BUTTON") {
                                    $(".uiTypeBu").attr("checked", true);
                                } else {
                                    $(".uiTypeMu").attr("checked", true);
                                }
                                 
                                
                                if(treeNode.argeSeqno != "" && treeNode.argeSeqno != null && treeNode.argeSeqno != undefined){
                                    $("#argeSeqnoE").val(treeNode.argeSeqno);
                                }else{
                                    $("#argeSeqnoE").val("");
                                }
                            })
        })

        function beforeClick(treeId, treeNode) {
            //如果是父节点，则展开或收缩子节点
            if (treeNode.isParent) {
                $.fn.zTree.getZTreeObj(treeId).expandNode(treeNode, null, true);
            }
            $("#uiNm").val(treeNode.uiNm);
            $("#urlAddr").val(treeNode.urlAddr);
            if(treeNode.iconUrlAddr != '' && treeNode.iconUrlAddr != null && typeof treeNode.iconUrlAddr != 'undefined'){
                $("#iconUrlAddr").attr("src",ipAddr+treeNode.iconUrlAddr);
            }else{
                $("#iconUrlAddr").attr("src","/fupin/dest/images/helppoor/personIcon.gif");
            }
            if(treeNode.iconUrlAddrSelected != '' && treeNode.iconUrlAddrHover != null && typeof treeNode.iconUrlAddrSelected != 'undefined'){
                $("#iconUrlAddrHover").attr("src",ipAddr+treeNode.iconUrlAddrHover);
            }else{
                $("#iconUrlAddrHover").attr("src","/fupin/dest/images/helppoor/personIcon.gif");
            }
            if(treeNode.iconUrlAddrSelected != '' && treeNode.iconUrlAddrSelected != null && typeof treeNode.iconUrlAddrSelected != 'undefined'){
                $("#iconUrlAddrSelected").attr("src",ipAddr+treeNode.iconUrlAddrSelected);
            }else{
                $("#iconUrlAddrSelected").attr("src","/fupin/dest/images/helppoor/personIcon.gif");
            }
            $("#uiPrivCd").val(treeNode.uiPrivCd);
            $("#uiDesc").val(treeNode.uiDesc);
           // showAreaTree(treeNode.uiRegnList,treeNode.addrLvlCd);
            
            if (treeNode.uiTypeCd == "BUTTON") {
                $(".uiTypeBuShow").attr("checked", true);
            } else {
                $(".uiTypeMuShow").attr("checked", true);
            }
            
        
            
            
            //$("#J_seqno").val(treeNode.ARGE_SEQNO);
            if(treeNode.argeSeqno != "" && treeNode.argeSeqno != null && treeNode.argeSeqno != undefined){
                $("#J_seqno").val(treeNode.argeSeqno);
            }else{
                $("#J_seqno").val("");
            }
            
            return true;
        }

        function beforeRemove(treeId, treeNode) {
            var dialog = Util.dialog.openDiv({
                content : "确认删除节点 " + treeNode.uiNm + " 吗？",
                title : '提示',
                width : "300px",
                height : "50px",
                modal : true,
                okVal : '确定',
                okCallback : delOk,
                cancelVal : '取消',
                cancelCallback : {}
            })
            return false;
        }

        //初始化树结构
        var initTree = function(uiId) {
            Util.ajax.postJson('/queryUiList', '', function(json,status) {
                if (status) {
                    
                     $.fn.zTree.init($("#J_zTree"), setting, json.object);

                   /*  if(uiId){
	                    var zTree = jQuery.fn.zTree.getZTreeObj("J_zTree");
	                    //var zTreeNode = jQuery.fn.zTree.getZTreeObj(uiId);
	                    //alert(zTreeNode);
	                    var zTreeNode = zTree.getNodesByParam("uiId",uiId,null);
	                    //console.log(zTreeNode);
	                    //var parentNode = zTreeNode[0].getParentNode();
	                    zTree.selectNode(zTreeNode[0]);  
	                    zTree.expandNode(zTreeNode[0],true,false,true);
                    }  */
                }
            });

        }
        var addOk = function() {
            _validator = $('#J_formAdd').validate({
                  rules: {
                      uiNm: {
                      required: true,
                      maxlength:80,
                      string:true
                    },
                    uiTypeCd: {
                          required: true
                        },
                    urlAddr: {
                          maxlength:80
                        },
                    uiPrivCd: {
                          required: true,
                          maxlength:80
                        },
                  
                    uiDesc: {
                          maxlength:150,
                          string:true
                    }
                  }, 
                  messages:{
                      uiNm:{
                      required:'界面名称为必填项', 
                      maxlength:'最大输入长度为80'
                    },
                    uiTypeCd: {
                          required: '界面类型为必填项', 
                        },                   
                    uiPrivCd: {
                      required: '界面权限代码为必填项', 
                      maxlength:'最大输入长度为80'
                    },
                    
                    uiDesc: {
                              maxlength:'最大输入长度为150'
                        }
                  }, 
                  showErrors:function(errorMap, errorList){
                    this.defaultShowErrors();
                  }
                });
             if (_validator.form()){
                /*  var seqno = $("#argeSeqNo").val();
                 var exg = /^[1-9]\d*$/;                
                 if(!exg.test(seqno)){
                     Util.dialog.tips("排序序号必须为大于0的整数");
                     return false;
                 } */
                  
                var zTree = $.fn.zTree.getZTreeObj("J_zTree"), nodes = zTree
                        .getSelectedNodes(), treeNode = nodes[0]
                                   
                var datas = $('#J_formAdd').serialize();
                if(treeNode){
                    var zTreeNode = zTree.getNodesByParam("uiId",treeNode.uiId,null);
                }                              
                
                var datas = $('#J_formAdd').serialize();
                   
                if (nodes.length > 0) {
                    datas += "&superMenuId=" + treeNode.uiId;
                    //alert(treeNode.uiId);
                }
                Util.ajax.postJsonSync("/saveUiInfo",datas,function(json,status){
                    if(status){
                 	   if(json.bean.rtnCd == "00"){        		   
                            //window.parent.inint();
                            //window.parent.closeIframeDialog();
                        }else{              
                            //window.parent.setTip("保存失败",top,2000);
                        }
                    }else{
                        Util.dialog.tips("保存失败,请重试!!");
                    }
              	}); 
              }
             else
             {
                 return false;
            }
        }
        var editOk = function() {
            _validator = $('#J_formEdit').validate({
                  rules: {
                         uiNm: {
                            required: true,
                              maxlength:80,
                              string:true
                          },
                        uiTypeCd: {
                            required: true
                        },
                        urlAddr: {
                              //required: true,
                              maxlength:80
                        },
                        uiPrivCd: {
                             required: true,
                              maxlength:80
                        },                        
                        argeSeqno:{
                            required: true
                        },
                        uiDesc: {
                              maxlength:150,
                              string:true
                        }
                  }, 
                  messages:{
                      uiNm:{
                          required:'界面名称为必填项', 
                          maxlength:'最大输入长度为80'
                    },
                    uiTypeCd: {
                          required: '界面类型为必填项', 
                        },
                    //urlAddress: {
                    //      required: 'URL参数为必填项', 
                   //       maxlength:'最大输入长度为80'
                   //     },
                    uiPrivCd: {
                          required: '界面权限代码为必填项', 
                          maxlength:'最大输入长度为80'
                        },
                    argeSeqno:{
                        required: "排序序号为不填项"
                    },
                    uiDesc: {
                          maxlength:'最大输入长度为150'
                        }
                  }, 
                  showErrors:function(errorMap, errorList){
                    this.defaultShowErrors();
                  }
                });
             if (_validator.form()){
                 /* var seqno = $("#SEQNO").val();
                 var exg = /^[1-9]\d*$/;
                 //alert(exg.test(seqno));return;
                 if(!exg.test(seqno)){
                     Util.dialog.tips("排序序号必须为大于0的整数");
                     return false;
                 } */
                var zTree = $.fn.zTree.getZTreeObj("J_zTree"), nodes = zTree
                        .getSelectedNodes(), treeNode = nodes[0]
                
               
               
                var datas = $('#J_formEdit').serialize();
                if(treeNode){
                    var zTreeNode = zTree.getNodesByParam("uiId",treeNode.uiId,null);
                    //console.log(zTreeNode);
                    var parentNode = zTreeNode[0].getParentNode();
                }
                datas += "&uiId=" + treeNode.uiId;
                Util.ajax.postJson('/editUiInfo', datas, function(json,status) {
                    if (status) {
                        $("#uiNm").val("");
                        $("#urlAddr").val("");
                        $("#iconUrlAddr").attr("src","/fupin/dest/images/helppoor/personIcon.gif");
                        $("#iconUrlAddrHover").attr("src","/fupin/dest/images/helppoor/personIcon.gif");
                        $("#iconUrlAddrSelected").attr("src","/fupin/dest/images/helppoor/personIcon.gif");
                        $("#uiPrivCd").val("");
                        $("#uiDesc").val("");
                        $("#argeSeqno").val("");
                        $("#J_seqno").val("");
                        $(".uiTypeBuShow").attr("checked", false);
                        $(".uiTypeMuShow").attr("checked", false);
                        
                        Util.dialog.tips("功能模块编辑成功！");
                        
                        if(parentNode){
                            initTree(parentNode.uiId);
                        }else{
                            initTree();
                        }
                    }else {
                        Util.dialog.tips(json.returnMessage);
                    }
                });
              }
             else
             {
                 return false;
            }
        }
        var delOk = function() {
            var zTree = $.fn.zTree.getZTreeObj("J_zTree"), nodes = zTree
                    .getSelectedNodes(), treeNode = nodes[0]
            Util.ajax.postJson('/delUiInfo', "uiId=" + treeNode.uiId,
                    function(json, status) {
                        if (json.returnCode == 0) {
                            if (status) {
                                $("#uiNm").val("");
                                $("#urlAddr").val("");
                                $("#uiPrivCd").val("");
                                $("#uiDesc").val("");
                                $("#J_seqno").val("");
                                $(".uiTypeBuShow").attr("checked", false);
                                $(".uiTypeMuShow").attr("checked", false);
                                $("#no_flag").attr("checked", false);
                                $("#no_flag").attr("checked", false);
                                
                                
                                Util.dialog.tips("功能模块删除成功！");
                                
                               
                                if(parentNode){
                                    initTree(parentNode.uiId);
                                }else{
                                    initTree();
                                }
                            }else {
                                Util.dialog.tips(json.returnMessage);
                            }
                        } else {
                            Util.dialog.tips(json.returnMessage);
                        }
                    });
        }
        jQuery.validator.addMethod("alnum", function(value, element) {
            return this.optional(element) || /^[a-zA-Z0-9]+$/.test(value);
            }, "只能包括英文字母和数字");
        jQuery.validator.addMethod("string", function(value, element) {
            return this.optional(element) || /^[\u0391-\uFFE5\w]+$/.test(value);
            }, "不允许包含特殊符号!")
            
            
    //获取省下拉列表
    function getProvOptions(val,provId,flag){
                var param = {regnCode:val};
                Util.ajax.postJsonSync(srvMap.get("queryRegnOptions"), param, function(json,status){
                    if(status){
                        provInfoList  =json;
                        if(flag=="0"){
                            Util.ajax.loadTemp("#"+provId,$("#T_provCodeDisable"),json);//加载模板
                        }else{
                            Util.ajax.loadTemp("#"+provId,$("#T_provCodeAble"),json);//加载模板
                        }
                    }else{
                        Util.dialog.tips("获取区域数据错误,请重试");
                    }
                });
    }
        //获取子系统列表
     function getSubSystemCode(val,sysytemId,flag){
                 var param = {cmnCd:val};
                 Util.ajax.postJsonSync(srvMap.get("initOptionVal"), param, function(json,status){
                     if(status){
                         provInfoList  =json;
                         if(flag=="0"){
                             Util.ajax.loadTemp("#"+sysytemId,$("#T_subSystemCdDisable"),json);//加载模板
                         }else{
                             Util.ajax.loadTemp("#"+sysytemId,$("#T_subSystemCdAble"),json);//加载模板
                         }
                     }else{
                         Util.dialog.tips("获取所属子系统失败,请重试");
                     }
                 });
     }  
        
    function getChlidProvOptions(val,provId,flag){
        var param = {uiId:val};
        Util.ajax.postJsonSync(srvMap.get("queryUiRegnOptions"), param, function(json,status){
            if(status){
                provInfoList  =json;
                if(flag=="0"){
                    Util.ajax.loadTemp("#"+provId,$("#T_provCodeDisable"),json);//加载模板
                }else{
                    Util.ajax.loadTemp("#"+provId,$("#T_provCodeAble"),json);//加载模板
                }
            }else{
                Util.dialog.tips("获取区域数据错误,请重试");
            }
        });
    }
    
    //新增ICON URL上传初始化
        function initWeb(fileList,picBtn,filePath,fileNm){
            //webuploader
            var $ = jQuery,
                    $list = $(fileList),
            // 优化retina, 在retina下这个值是2
                    ratio = window.devicePixelRatio || 1,

            // 缩略图大小
                    thumbnailWidth = 60 * ratio,
                    thumbnailHeight = 60 * ratio,

            // Web Uploader实例
               uploader;
               var familyPicUrls = '';
               var allPicUrls = '';//包含所有前端页面预览过的图片的地址
            // 初始化Web Uploader
            uploader = WebUploader.create({
                // 自动上传。
                auto: true,

                // 图片上传前进行压缩
                compress: false,
                 duplicate :true,  
                // swf文件路径
                swf:  '../../asset/lib/webuploader/Uploader.swf',
                // 文件接收服务端。
                //server: '../../front/sh/poorHouse!uploadPicImg?uid=p001',
                server:'../../front/sh/poorHouse!uploadPicImg?uid=p001',
                // 选择文件的按钮。可选。
                // 内部根据当前运行是创建，可能是input元素，也可能是flash.
                pick: {id:picBtn,multiple:false},
                // 只允许选择文件，可选。
                accept: {
                    title: 'Images',
                    extensions: 'gif,jpg,jpeg,bmp,png',
                    mimeTypes: 'image/jpg,image/jpeg,image/png,image/bmp,image/gif'
                },
                 fileVal: "file",
                 fileSingleSizeLimit:3145728
            });

            // 图片上传前，尝试将图片压缩到1080 * 700
           /*  uploader.option( 'compress', {
              width: 1080,
                height: 700,
                allowMagnify: true,
                crop: true
            }); */
            
          //图片加入队列前,判断图片大小
            uploader.on('beforeFileQueued',function(file){
                  var picUpload = $(fileList).find(".file-item");
                  if(file.size > 3145728){
                      Util.dialog.tips("图片大于3M，请重新选择",top,1000);
                  }
            })
            uploader.on( 'uploadStart', function( file ) {});
            // 当有文件添加进来的时候
            uploader.on( 'fileQueued', function( file ) { 
                var strNum = fileList.substring(10);//#fileList1
                var $li = $(
                        '<div id="' + file.id + '" class="file-item thumbnail" style="width:60px;">' +
                        '<img>' +
                        '<div class="delpic" style="display:none"><span style="color: #08c;" attr_num="'+strNum+'" onclick="delUploadPic(this);">删除图片</span></div><div class="excelProcess" style="visibility:hidden;"></div></div>'
                ),
                $img = $li.find('img');
                $(fileList).show();                 
                $(fileList).append( $li );
                if(!!window.ActiveXObject || "ActiveXObject" in window){ 
                    $(fileList).parent().css({'overflow':'hidden','height':'108px'});                   
                }else{
                    $(fileList).next('.img_btn').hide();
                }
            // 创建缩略图
            uploader.makeThumb( file, function( error, src ) {
                if ( error ) {
                    $img.replaceWith('<span>不能预览</span>');
                    return;
                }   
                $img.attr( 'src', src );
            }, thumbnailWidth, thumbnailHeight );
            });

            // 文件上传过程中创建进度条实时显示。
            uploader.on( 'uploadProgress', function( file, percentage ) {
                $('#'+file.id).find('.excelProcess').css('visibility','visible');
                $('#'+file.id).find('.excelProcess').html('<p class="progress" style="width:'+percentage * 99+'%"></p><span>'+(percentage.toFixed(2)* 99)+'%</span>');
            });
            // 文件上传成功，给item添加成功class, 用样式标记上传成功。
            uploader.on( 'uploadSuccess', function(file, data) {
                var picUrl = data.bean.picUrl;
                var imgName = data.bean.fileName;
                var ftpUrl = data.bean.ftpUrl;
                var strNum = fileList.substring(10);//#fileList1
                $("#filePath"+strNum).val(picUrl);//最终上传图片
                $("#fileName"+strNum).val(imgName);
                $( '#'+file.id ).addClass('upload-state-done');
                $('#'+file.id).find('.delpic').show();
                $('#'+file.id).find('.excelProcess').hide();
                
            });

            // 文件上传失败，显示上传出错。
            uploader.on( 'uploadError', function( file ) {
                var $li = $( '#'+file.id ),
                        $error = $li.find('div.error');
                if ( !$error.length ) {
                    $error = $('<div class="error"></div>').appendTo( $li );
                }
                $("#"+file.id).parent().parent('.img_thumbnail').hide();
                $("#"+file.id).parent().parent('.img_btn').show();
                $("#"+file.id).parent().parent('.img_btn').css({'height':'60px'});
                Util.dialog.tips('上传失败');
                $("#"+file.id).remove();
            });

            // 完成上传完了，成功或者失败，先删除进度条。
            uploader.on( 'uploadComplete', function( file ) {
               // $( '#'+file.id ).find('.progress').remove();
            });
            
          //解决ie9下上传png无法到后台的问题
            if(navigator.userAgent.indexOf("MSIE")>0 && navigator.userAgent.indexOf("MSIE 9.0")>0){   
              var setHeader = function(object, data, headers) {
                    headers['Access-Control-Allow-Origin'] = '*';
                    headers['Access-Control-Request-Headers'] = 'content-type';
                    headers['Access-Control-Request-Method'] = 'POST';
                }
              uploader.on('uploadBeforeSend ', setHeader);
            }
        }
    //删除icon图标
    function delPicF(obj,num){
         $('#filePath'+num).val('');
         $('#fileName'+num).val('');
         //$(_this).parent().parent().parent().parent().parent().find('.fileName').val('');
         //$(_this).parent().parent().parent().parent().parent().find('.filePath').val('');
         $(obj).parent().parent().parent().parent().find('.img_thumbnail').hide();
         $(obj).parent().parent().parent().parent().find('.img_btn').show();
         $(obj).parent().parent().parent().parent().find('.file-item').remove();
    }
    //上传成功之后的，删除icon图标
    function delUploadPic(obj){
        var _this=$(obj);
        var strNum = _this.attr('attr_num');//#fileList1
        $("#filePath"+strNum).attr('value','');//最终上传图片
        $("#fileName"+strNum).attr('value','');
        _this.parent().parent().parent('.img_thumbnail').hide();
        _this.parent().parent().parent('.img_thumbnail').next('.img_btn').show();
        if(!!window.ActiveXObject || "ActiveXObject" in window){                   
            _this.parent().parent().parent('.img_thumbnail').next('.img_btn').css({'height':'60px'});
        }
        _this.parent().parent('.file-item').remove();
    }
    
    //详情页面的树展示：只展示已有的
    function showAreaTree(list,addrLvlCd){
    	var regnStrProv = list.map(function(x){return x.REGN_CODE.substring(0,2)+"0000000000"});
		var regnStrCity = list.map(function(x){return x.REGN_CODE.substring(0,4)+"00000000"});
		var regnStrCnty = list.map(function(x){return x.REGN_CODE.substring(0,6)+"000000"});
		Util.ajax.postJsonSync(srvMap.get('queryRegnOptions'),{regnCode:"-1"}, function(json, status) {
			if (status) {
				$.fn.zTree.init($("#areaTreeShow"), settingAreas, json.beans);
				var areaTree =  $.fn.zTree.getZTreeObj("areaTreeShow");
				if("1001" == addrLvlCd){
					//选择省
					regnStrProv.map(function(x){
						areaTree.checkNode(areaTree.getNodeByParam("regnCode",x,null))
					});
				}else if("1002" == addrLvlCd){
					//点击省，选择市
					regnStrProv.map(function(x){
						areaTree.setting.callback.onClick(null, areaTree.setting.treeId, 
								areaTree.getNodeByParam("regnCode",x,null));
					});
					regnStrCity.map(function(x){
						areaTree.checkNode(areaTree.getNodeByParam("regnCode",x,null))
					});
				}else if("1003" == addrLvlCd){
					//点击省、市，选择县
					regnStrProv.map(function(x){
						areaTree.setting.callback.onClick(null, areaTree.setting.treeId, 
								areaTree.getNodeByParam("regnCode",x,null));
					});
					regnStrCity.map(function(x){
						areaTree.setting.callback.onClick(null, areaTree.setting.treeId, 
								areaTree.getNodeByParam("regnCode",x,null));
					});
					regnStrCnty.map(function(x){
						areaTree.checkNode(areaTree.getNodeByParam("regnCode",x,null))
					});
				}
				var nodes = areaTree.getCheckedNodes(false);
				nodes.map(function(x){
					var totalStr = [regnStrProv,regnStrCity,regnStrCnty].join(",") 
					if(totalStr.indexOf(x.regnCode) == -1){
						areaTree.removeNode(x);
					}
				});
				/* $('.disable_div_warp').height($('#areaTreeShow').parents('.form_container').height()) */
			}
		});
    }    
    
    //编辑时初始化区域树
    function editInitAreaTree(){
    	var regnStr = $("#regnStr").val() || '';
    	var addrLvlCd = $("#addrLvlCd").val();
    	var areaTree =  $.fn.zTree.getZTreeObj("areaTree");
    	if(regnStr){
    		if(regnStr){
				var regnStrProv = regnStr.split(",").map(function(x){return x.substring(0,2)+"0000000000"});
				var regnStrCity = regnStr.split(",").map(function(x){return x.substring(0,4)+"00000000"});
				var regnStrCnty = regnStr.split(",").map(function(x){return x.substring(0,6)+"000000"});
				if("1001" == addrLvlCd){
					//选择省
					regnStrProv.map(function(x){
						areaTree.checkNode(areaTree.getNodeByParam("regnCode",x,null))
					});
				}else if("1002" == addrLvlCd){
					//点击省，选择市
					regnStrProv.map(function(x){
						areaTree.setting.callback.onClick(null, areaTree.setting.treeId, 
								areaTree.getNodeByParam("regnCode",x,null));
					});
					regnStrCity.map(function(x){
						areaTree.checkNode(areaTree.getNodeByParam("regnCode",x,null))
					});
				}else if("1003" == addrLvlCd){
					//点击省、市，选择县
					regnStrProv.map(function(x){
						areaTree.setting.callback.onClick(null, areaTree.setting.treeId, 
								areaTree.getNodeByParam("regnCode",x,null));
					});
					regnStrCity.map(function(x){
						areaTree.setting.callback.onClick(null, areaTree.setting.treeId, 
								areaTree.getNodeByParam("regnCode",x,null));
					});
					regnStrCnty.map(function(x){
						areaTree.checkNode(areaTree.getNodeByParam("regnCode",x,null))
					});
				}
			}
		}
    }
    
    var settingAreas = {
			view: {
				selectedMulti: true
			},
			check: {
				enable: true,
				chkStyle: "checkbox",
				chkboxType:{ "Y" : "s", "N" : "s" }
			},
			data: {
				simpleData: {
					enable: true,
					idKey: "regnCode",
					pIdKey: "suprRegnCode",
					rootPId: -1
				},
				key: {
					name: "regnNm"
				}
			},
			callback: {
				onClick: zTreeOnClick
			}
		};
		function zTreeOnClick(event, treeId, treeNode) {
			var addrLvlCd = $("#addrLvlCd").val();
			if(addrLvlCd == '1001'){
				//省级只能选择省
				return  false;
			}else if(addrLvlCd=='1002' && treeNode.regnCode.substr(2,2) != '00'){
				//市级可以选择到市
				return false;
			}else if(addrLvlCd=='1003' && treeNode.regnCode.substr(4,2) != '00'){
				//县级可以选择到县
				return false
			}else if (treeNode.children!=null && treeNode.children.length!=null && treeNode.children.length>0){
				return false;
			}else {
				Util.ajax.postJsonSync(srvMap.get('queryRegnOptions'),{regnCode:treeNode.regnCode}, function(json, status) {
					if (status) {
						var treeObj = $.fn.zTree.getZTreeObj(treeId);
						var newNodes = json.beans;
						if(upAddrLvl && upRegnStr){
							if(treeNode.level ==  "0" && upAddrLvl > 1001){
								//点击省时，过滤市
								var regnStr = upRegnStr.split(",").map(function(x){return x.substring(0,4)+"00000000"});
								newNodes = newNodes.filter(function(x){return regnStr.indexOf(x.regnCode) > -1});
							}else if(treeNode.level ==  "1" && upAddrLvl > 1002){
								//点击市时，过滤县
								var regnStr = upRegnStr.split(",").map(function(x){return x.substring(0,6)+"000000"});
								newNodes = newNodes.filter(function(x){return regnStr.indexOf(x.regnCode) > -1});
							}
						}
						newNodes = treeObj.addNodes(treeNode, newNodes);
					}
				});
			}
		}
    </script>
</body>
</html>
